<?php
	global $wpdb;
	$table_name = $wpdb->prefix . "spec_package";
	$info=$_REQUEST["info"];
	if($info=="saved")
	{
		echo "<div class='updated' id='message'><p><strong>Package Added</strong>.</p></div>";
	}
	if($info=="upd")
	{
		echo "<div class='updated' id='message'><p><strong>Record Updated</strong>.</p></div>";
	}
	if($info=="del")
	{
		$delid=$_GET["did"];
	//$wpdb->query("delete from ".$table_name." where id=".$delid);
		$wpdb->query("UPDATE  `wp_spec_package` SET  `status` =  '1' WHERE  `wp_spec_package`.`id` =".$delid);
		
	
		
		echo "<div class='updated' id='message'><p><strong>Record Deleted.</strong>.</p></div>";
	}
?>

<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){
		jQuery('#memberlist').dataTable();
	});
	/* ]]> */

</script>


<div class="wrap">
    <h2>List of Packages &nbsp;&nbsp;<a class="button add-new-h2" href="admin.php?page=package_add&act=add">Add New</a></h2>
	 <table class="wp-list-table widefat fixed " id="memberlist">
		<thead>
			<tr>
				<th width="8%"><u>ID</u></th>
				<th width="20%"><u>Name</u></th>
				<th width="40%"><u>Description</u></th>
				<th width=""><u>Terms</u></th>
				<th  width="10%">Options</th>
			</tr>
		</thead>
		<tbody>
<?php
		$sql = "select * from ".$table_name." WHERE type= 'Package' AND status = 0";
		$result = mysql_query($sql) or die ('Error, query failed');
		if (mysql_num_rows($result) > 0 )
		{
		?>
				<script type="text/javascript">
				/* <![CDATA[ */
				jQuery(document).ready(function(){
					jQuery('#mytable').dataTable();
				});
				/* ]]> */

			</script>
<?php
			while ($row = mysql_fetch_assoc($result))
			{
				$id       		 = $row['id'];
				$name     		 = $row['name'];
				$description     = $row['description'];
				$terms  		 = $row['terms'];
				$link      		 = $row['link'];
	?>
			<tr>
				<td><?php echo $id; ?></td>
				<td nowrap><?php echo $name; ?></td>
				<td nowrap><?php echo $terms; ?></td>
				<td nowrap><?php echo $description; ?></td>
			
				<td><u><a href="admin.php?page=package_add&act=upd&id=<?php echo $id;?>">Edit</a>&nbsp;|&nbsp;<a href="admin.php?page=myplug/muyplg.php&info=del&did=<?php echo $id;?>">Delete</a></u></td>
			
			</tr>
<?php }
	} else { ?>
			<tr>
				<td>No Record Found!</td>
			<tr>
	<?php } ?>
	</tbody>
	</table>
</div>